<?php 
    $url = new Url();      
    $link_url = Yii::app()->params['urlRs']."/upload/upload_library.php?forder_up=assignment";
?> 

<link href="<?php echo Yii::app()->params['urlRs']; ?>/js/swfupload/css/default.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="<?php echo Yii::app()->params['urlRs']; ?>/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlRs']; ?>/js/swfupload/js/handlers.js"></script>

<div id="content" class="clearfix">        

    <div id="homeContentRight" class="contentWrap ut-TEACHER">

        <?php $this->widget("LeftBar");?> 

        <div id="content_middle">
            <div class="feedTitleWrap clearfix">
                <h1 id="feedTitle"><p class="eIcon">Nhóm <?php echo $data_group['group_name'] ?></p></h1>                                         
            </div>
            <div class="postBoxFeedWrap">
                <div id="postBoxWrap" class="clearfix">
                    <p class="pbLabel">Gửi:</p>
                    <div class="PostBox">
                        <div class="post-types">
                            <a class="note" href="<?php echo $url->createUrl("group/index",array("group_id"=>$_GET["group_id"])); ?>">Ghi chú</a>
                            <a class="assignment active" href="<?php echo $url->createUrl("group/assignment",array("group_id"=>$_GET["group_id"])); ?>">Bài tập</a>
                            <a class="alert">Báo động</a>                            
                            <a class="quiz">Câu hỏi</a>
                            <a class="poll">Bình chọn</a>
                        </div>

                        <?php if($data_group['groưp_teacher_id'] == $data_user['user_id']){ ?>
                        <div class="entry-boxes">                            

                            <div class="AssignmentEntry">
                                <input type="text" tabindex="39" class="title" id="assignment_title">
                                <input type="button" tabindex="40" class="load" value="Gửi bài tập" style="margin-top: 5px;" onclick="send_asignment(<?php echo $data_group['group_id']; ?>,<?php echo $data_user['user_id']; ?>)">
                                <div style="display: none;" class="err" id="assignment_title_error">You must select an assignment title</div>
                                <textarea tabindex="41" style="overflow: hidden;" id="assignment_description"></textarea>
                                <div style="display: none;" class="err">You must type a description.</div>
                                <div>
                                    <input type="text" id="txtFileName" disabled="disabled" style="background-color: #FFFFFF;" size="55" value="" />                            
                                    <span id="spanButtonPlaceholder"></span>
                                </div>                        
                                <div class="flash" id="divFileProgressContainer"></div>
                                <!--<div class="date"><input type="text" tabindex="42" class="dp-applied">                                    
                                <div style="display: none;" class="err">You must set a Due Date</div>
                                <div class="err" style="display: none;">Date format is invalid.</div>
                                </div>-->
                                <div style="position: absolute; left: -999em; top: 0px; word-wrap: break-word; border-left: 1px solid rgb(170, 204, 229); border-color: rgb(170, 204, 229); border-style: solid; border-width: 1px; font-weight: 400; width: 510px; font-family: 'Helvetica Neue','Nimbus Sans L',Arial,Helvetica,sans-serif; line-height: 15px; font-size: 12px; padding: 3px;" class="elastic-div">&nbsp;</div>
                            </div>

                        </div>
                        <?php } ?>

                    </div>
                </div>
                <div id="message-feed">                    
                    <ul id="feed" class="feed-container">    
                        <?php foreach($post_data as $row_post){ ?>    
                            <li id="fmsg-74673511" class="post-entry delete_rights">
                                <a class="avatar" href="javascript:">
                                    <img class="small_avatar" src="<?php echo Yii::app()->params['urlRs'];?>/images/9_0_t.png" alt="iColdStyle">
                                </a>
                                <div class="textpost">
                                    <div class="msg-info">
                                        <span class="msg-receiver sender-name"><?php echo $row_post['sender_name']; ?></span> gửi tới <a class="msg-receiver" style="color:#336699" href="javascript:"><?php echo $data_group['group_name'] ?></a>        
                                    </div>
                                    <div class="msg-content-container">

                                        <div class="msg-content-text" id="msg-content-text-79286420">
                                                      
                                            <p class="assignment-title"><?php echo $row_post['assignment_title']; ?></p>
                                            <div due_date="10/19/2012" class="assignment-info">
                                                <?php if($_SESSION["user_edu_net"]["user_id"] == $data_group["groưp_teacher_id"]){ ?>
                                                    <a href="<?php echo $url->createUrl("group/grade",array('group_id'=>$data_group["group_id"],'assignment_id'=>$row_post["assignment_id"])); ?>" class="nice-button ass-link">Chấm điểm <span class="turned-in-count"><!--(1)--></span></a>
                                                <?php }else{ 
                                                    $turn_in = 0;
                                                    $grade = null;
                                                    foreach($data_exercise as $check){
                                                        if($check['assignment_id'] == $row_post["assignment_id"]){
                                                            $turn_in = 1;
                                                            $grade = $check['exercise_grade'];
                                                        }
                                                    }
                                                    if($turn_in == 0){
                                                    ?>                                            
                                                    <a href="<?php echo $url->createUrl("group/turnin",array('group_id'=>$data_group["group_id"],'assignment_id'=>$row_post["assignment_id"])); ?>" class="nice-button ass-link">Nộp bài <span class="turned-in-count"><!--(1)--></span></a>
                                                <?php }else{ ?>
                                                    <a href="javascript:" class="nice-button ass-link assign-results">Đã nộp <span class="turned-in-count">(<?php if($grade == null){ echo "Chưa có điểm"; }else{ echo $grade." điểm"; } ?>)</span></a>                                                    
                                                <?php } } ?>
                                                <!--<div class="due-date">
                                                DUE: 
                                                <p>Oct 19, 2012</p>
                                                </div>-->
                                            </div>
                                            <p id="assignment-description-79286420" class="assignment-description"><?php echo $row_post['assignment_description']; ?></p>

                                        </div>                                        

                                        <ul class="msg-additional-content">
                                            <li>
                                                <div class="link-wrap txt ">
                                                    <div class="link-thumb-wrap"><img class="icon txt" src="<?php echo Yii::app()->params['urlRs'];?>/images/txt.png"></div>
                                                    <div class="link-info">
                                                        <a href="<?php echo Yii::app()->params['urlRs'];?>/upload_data<?php echo $row_post['assignment_link']; ?>" class="link_title"><?php echo $row_post['assignment_file_name']; ?></a>
                                                        <div class="block-clear"></div>
                                                        <a href="<?php echo Yii::app()->params['urlRs'];?>/upload_data<?php echo $row_post['assignment_link']; ?>" id="doc-viewer-preview-79286420-31767595" class="doc-view-preview">Download</a>
                                                        <span id="doc-viewer-79286420-31767595" class="doc-viewer"></span>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>

                                    </div>
                                </div>
                                <ul class="post-entry-footer">
                                    <li class="time-ago"><?php echo date('j',$row_post['assignment_create_date']); ?> tháng <?php echo date('m',$row_post['assignment_create_date']); ?>, <?php echo date('Y',$row_post['assignment_create_date']); ?></li>
                                    <li class="msg-reply"><?php echo date('H:i',$row_post['assignment_create_date']); ?></li>
                                </ul>
                                <div class="clear-div"></div>
                                <ul id="comments-74673511" class="comments">
                                    <?php foreach($post_reply as $row_reply){ if($row_reply['rAssign_assignment_id'] == $row_post['assignment_id']){  ?>    
                                            <li id="comment-content-80642185" class="comment-content">
                                                <a class="comment-avatar" href="javascript:"><img class="small_avatar" src="<?php echo Yii::app()->params['urlRs'];?>/images/default_avatar_t.png"></a>
                                                <div class="comment-right ">
                                                    <span class="comment-wrapper comment-wrapper-full"> 
                                                        <a class="sender-lnk" href="javascript:"><?php echo $row_reply['sender_name']; ?></a> -
                                                        <span class="commentTxt"><?php echo $row_reply['rAssign_content']; ?></span>
                                                    </span>
                                                    <ul class="extra-info">
                                                        <li class="time-ago"><?php echo date('j',$row_reply['rAssign_create_date']); ?> tháng <?php echo date('m',$row_reply['rAssign_create_date']); ?>, <?php echo date('Y',$row_reply['rAssign_create_date']); ?></li> 
                                                        <li class="msg-reply"><?php echo date('H:i',$row_post['rAssign_create_date']); ?></li>
                                                    </ul>
                                                </div>
                                            </li>
                                            <?php } } ?>
                                </ul>
                                <div class="reply-container comment-reply" >
                                    <img class="avatar small_avatar" src="<?php echo Yii::app()->params['urlRs'];?>/images/default_avatar_t.png">
                                    <textarea class="message-comment-area" id="content_reply_<?php echo $row_post['assignment_id']; ?>" style="overflow: hidden; " onfocus="show_btn_reply(<?php echo $row_post['assignment_id']; ?>)">Trả lời...</textarea>                                    
                                    <p class="empty-reply-error" id="error_reply_<?php echo $row_post['assignment_id']; ?>" style="display: none;">Trả lời của bạn không được để trống!</p>
                                    <div id="btn_reply_<?php echo $row_post['assignment_id']; ?>" style="display: none;">                                        
                                        <input type="button" class="reply-btn blue-btn" value="Trả lời" onclick="send_reply(<?php echo $row_post['assignment_id']; ?>,<?php echo $_SESSION["user_edu_net"]['user_id']; ?>,<?php echo $data_group["group_id"]; ?>)">
                                        <input type="button" class="cancel-btn grey-btn mt0" value="Hủy bỏ">                                    
                                    </div>
                                </div>
                            </li>
                            <?php } ?>                
                    </ul>
                </div>
            </div>
        </div>

        <?php $this->widget("RightBar");?> 

    </div> 

</div>

<?php include "assignment.js.php"; ?>